/**
 *
 *  @auth xlx_good@qq.com
 *  @date 17/6/21.
 *
 */

requirejs.config({
    baseUrl: '/js/',
    paths:  {
        jquery: 'plugins/jquery/jquery-1.11.3.min',
        avalon: 'plugins/avalon/avalon.min',
        config: 'config',
        api: 'api',
        layer: 'plugins/layer/layer'
    },
    shim: {
        api: {
            deps: ['jquery']
        },
        layer: {
            deps: ['jquery']
        }
    }
});


(function(win, dom, requirejs, initVm){
    var vm, myChart, data;
    requirejs(['avalon', 'jquery','config', 'api', 'layer'], function(){
        //初始化vm
        vm = initVm(dom);
		//获取主页数据
		data = getHomeData(vm);
    });

})(window, document, requirejs, function(dom){
    var vm = avalon.define({
        $id: 'container',
        data: {}
    })
//    avalon.scan(dom.body); // 会调用两次
    return vm;
});
function getHomeData(vm) {
	Api.home(function(resp) {
		if(resp.code == 1) {
			vm.data = resp.data;
		} else {
			layer.msg(resp.msg);
		}
	}, function(XMLHttpRequest) {
		alert(XMLHttpRequest.responseText); 
	});
};
